package com.example.demo.controller;

import com.example.demo.component.UserComponent;
import com.example.demo.model.UserInfo;
import com.example.demo.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/controller")
public class UserController4 {
//    @Autowired
//    @Qualifier("user1")
//    private UserInfo userInfo;


//    @Autowired
//    private UserInfo userInfo;

    @Resource(name = "user2")
    private UserInfo userInfo;

//    private UserInfo userInfo;
    @Autowired
//    @Qualifier("us")
    private UserComponent userComponent;

//    @Autowired
//    @Qualifier("user3")
//    public void setUserInfo(UserInfo userInfo) {
//        this.userInfo = userInfo;
//    }


    @Autowired
    private UserService userService;

    @RequestMapping("/sayHello")
    public String sayHello(){
        userService.sayHi();
        System.out.println("UserController4");
        userComponent.sayHi();
        return userInfo.toString();
    }
}
